package dataManager;

import java.util.ArrayList;
import java.util.List;

import po.Business;
import po.Goods;

public class BusinessDataManager {
	private List<Business> listBusiness;
	private List<Business> listUnBusiness;
	
	public BusinessDataManager(){
		listBusiness=new ArrayList<Business>();
		listUnBusiness = new ArrayList<Business>();
	}
	
	public void addBusinessInMemory(Business e){
		System.out.println("addBusinessInMemory"+e.getBid());
		listBusiness.add(e);
	}
	
	public void addBusinessInTempMemory(Business e){
		listUnBusiness.add(e);
	}
	
	public int changeUnBusinessStatus(String bid){
		for(int i=0;i<listUnBusiness.size();i++){
			if(bid.equals(listUnBusiness.get(i).getBid()))
			{
				listBusiness.add(listUnBusiness.get(i));
				listUnBusiness.remove(i);
			}
		}
		return 0;
	}
	
	public List<Business> listUnBusinessByBid(String bid){
		List<Business> glist = new ArrayList<Business>();
		if(bid==null){
			return listUnBusiness;
		}else{
			for(Business g:listUnBusiness){
				if(bid.equals(g.getBid())){
					glist.add(g);
				}
			}
			return glist;
		}
	}
	public List<Business> listBusinessByBid(String bid){
		List<Business> glist = new ArrayList<Business>();
		if(bid==null){
			System.out.println("bid is null");
			return listBusiness;
		}else{
			for(Business g:listBusiness){
				if(bid.equals(g.getBid())){
					glist.add(g);
				}
			}
			return glist;
		}
	}
}
